<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:c="http://java.sun.com/jsf/composite/componentes"
                template="../template.xhtml">
    <ui:define name="conteudo">
        <h:form styleClass="form-estilo" prependId="false" rendered="#{listarMembro.autorizar('PAPEL_EDITAR_PERFIL')}">
            <h2>#{i18n.perfil_editar_titulo}</h2>
            <!--<h:outputLink id="txt_custom" value="#">Custom</h:outputLink>-->
            <!--p:tooltip for="txt_custom" value="Tooltip with custom style" style="myStyle" /-->
            <fieldset>
                <legend>Detalhes</legend>
                <h:link outcome="LISTAR_PERFIL_ENCAMINHAR">
                    <h:commandButton styleClass="commandButton" value="#{i18n.botao_voltar}"/>
                </h:link>
                <h:commandButton styleClass="commandButton" action="#{editarPerfil.salvar}" value="#{i18n.botao_salvar}"/>
                <br/><br/>
                <h:panelGrid columns="2">
                    <h:outputLabel value="#{i18n.perfil_nome}"/>
                    <h:inputText value="#{editarPerfil.objeto.nome}" label="#{i18n.perfil_nome}" required="true" requiredMessage="#{i18n.perfil_nome_mensagem}" size="50"/>
                </h:panelGrid>
                <br/>

                <p:tabView rendered="#{editarPerfil.objeto.id != null}">
                    <p:tab title="Papel">

                            <h:panelGrid columns="2">
                                <h:outputLabel value="#{i18n.papel_nome}"/>
                                <h:column/>
                                <h:inputText id="inputTextNome" value="#{editarPerfil.papel.nome}" size="50"/>
                                <h:outputLink title="clique aqui para consultar" value="javascript:void(0)" onclick="painelConsultarPapel.show()">
                                    <h:graphicImage value="#{resource['img:consultar.png']}" style="border: 0px;"/>
                                </h:outputLink>
                            </h:panelGrid>
                            <h:commandButton styleClass="commandButton" alt="clique para incluir papel" value="Incluir" actionListener="#{editarPerfil.incluir}">
                                <f:ajax execute="@form" render="@form"/>
                            </h:commandButton>
                            <p:dialog widgetVar="painelConsultarPapel" header="Consultar Papel" fixedCenter="true" effect="FADE" width="400px" height="320px">
                                <ui:include id="pagina" src="/seguranca/consultarPapel.xhtml">
                                    <ui:param name="alvo" value="#{editarPerfil.papel}"/>
                                </ui:include>
                            </p:dialog>
                            <p:dataTable id="dataTablePapel"
                                         var="papel"
                                         value="#{editarPerfil.objeto.papeis}"
                                         paginator="true" rows="5"
                                         firstPageLinkLabel="Primeiro"
                                         previousPageLinkLabel="Anterior"
                                         nextPageLinkLabel="Próximo"
                                         lastPageLinkLabel="Último">
                                <p:column width="400">
                                    <f:facet name="header">
                                        <h:outputText value="#{i18n.papel_descricao}"/>
                                    </f:facet>
                                    <h:outputText value="#{papel.descricao}"/>
                                </p:column>
                                <p:column width="50">
                                    <f:facet name="header">
                                        <h:outputText value="Remover"/>
                                    </f:facet>
                                    <h:commandLink actionListener="#{editarPerfil.remover(papel)}">
                                        <f:ajax execute="@form" render="@form"/>
                                        <h:graphicImage style="border: 0px;" value="#{resource['img:remover.png']}"/>
                                    </h:commandLink>
                                </p:column>
                            </p:dataTable>
                    </p:tab>
                </p:tabView>                
            </fieldset>
        </h:form>
    </ui:define>
</ui:composition>